home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 09, No. 08 (1988-08)(MicroSPARC)(Side A).zip / Nibble Volume 09, No. 08 (1988-08)(MicroSPARC)(Side A).po / GS.INFO.ASM.txt < prev    next >
Text File  |  1996-12-24  |  19KB  |  461 lines

  1. **************************
  2. *                        *
  3. *      GS INFO CDA       *
  4. *   by Sandy Mossberg    *
  5. *                        *
  6. *   Copyright (C) 1987   *
  7. *   by MicroSPARC, Inc.  *
  8. *   Concord, MA  01742   *
  9. *                        *
  10. **************************
  11.            SETCOM   36               ;comment line starts at 38
  12.            MCOPY    GS.INFO.MAC      ;name of macro file
  13.            KEEP     GS.INFO          ;name of load file
  14.  
  15. ***| EQUATES |***************************************************
  16.  
  17. ; Locations:
  18.  
  19. CH         GEQU     $24              ;column position
  20. CV         GEQU     $25              ;row position
  21. KVERSION   GEQU     $BFFF            ;ProDOS 8 minor version
  22. Key        GEQU     $E0C000          ;keyboard input
  23. Strobe     GEQU     $E0C010          ;keyboard strobe
  24. Toolbox    GEQU     $E10000          ;standard toolbox call
  25. OS_ID      GEQU     $E100BC          ;operating system ID
  26.  
  27. ; 80-column screen commands:
  28.  
  29. NORMAL     GEQU     $8E              ;enable normal text mode
  30. INVERSE    GEQU     $8F              ;enable inverse text mode
  31. HOME       GEQU     $99              ;home cursor (no scrn clear)
  32.  
  33. ***| MAIN PROGRAM |**********************************************
  34.  
  35. GS_Info    START
  36.            USING    GSI_Data
  37. ;................................................................
  38. ;
  39. ; CDA header:
  40. ;
  41.            STR      'GS Info'        ;title of CDA
  42.            DC       I4'GSI_Entry'    ;startup entry to CDA
  43.            DC       I4'GSI_Exit'     ;shutdown entry to CDA
  44. ;................................................................
  45. ;
  46. ; Initialize:
  47. ;
  48. GSI_Entry  PHB                       ;save entry data bank
  49.            PHK                       ;equate program bank
  50.            PLB                       ; to data bank
  51.            JSL      Set_S3           ;set text I/O for slot 3
  52. ;................................................................
  53. ;
  54. ; Print tool set info:
  55. ;
  56.            WRITECH  #INVERSE         ;set inverse text mode
  57.            WRITELN  #' Current Status of Tool Sets: '
  58.            WRITECH  #NORMAL          ;set normal text mode
  59.            WRITELN                   ;CR
  60.            LDA      #$601            ;start with STATUS call
  61.            STA      TS_Status        ; of 1st tool set
  62.            LDA      #$401            ;start with VERSION call
  63.            STA      TS_Version       ; of 1st tool set
  64.            STZ      Col_Flag         ;flag 1st column
  65.            STZ      TS_Loc           ;point at start of table
  66. Do_TS      LDY      TS_Loc
  67.            CPY      TS_Num
  68.            BCS      Do_Misc          ;tool sets completed
  69.            CPY      #14
  70.            BNE      DTS1             ;still at 1st column
  71.            LDA      #2               ;at 2nd column so return
  72.            JSR      SetCV            ; to top of list
  73.            LDA      #$8000           ; and flag the
  74.            STA      Col_Flag         ; 2nd column
  75. DTS1       JSR      Get_TS           ;print name of tool set
  76.            JSR      Prt_TSInfo       ;print tool set info
  77.            WRITELN                   ;CR
  78.            INC      TS_Status        ;bump status and version
  79.            INC      TS_Version       ; calls to next tool set
  80.            INC      TS_Loc           ;bump table position
  81.            BRA      Do_TS            ;loop back for more
  82. ;................................................................
  83. ;
  84. ; Print miscellaneous information:
  85. ;
  86. Do_Misc    WRITELN                   ;CR
  87.            WRITECH  #INVERSE         ;set inverse text mode
  88.            WRITELN  #' Miscellaneous Information: '
  89.            WRITECH  #NORMAL          ;set normal text mode
  90.            WRITELN                   ;CR
  91.            WRITESTR #'Total Memory: '
  92.            JSR      Get_TotalK       ;print total memory K
  93.            WRITELN                   ;CR
  94.            WRITESTR #'Free Memory : '
  95.            JSR      Get_FreeK        ;print free memory K
  96.            WRITELN                   ;CR
  97.            WRITESTR #'> Free Block: '
  98.            JSR      Get_BigK         ;print largest block K
  99.            LDA      #19              ;start new column
  100.            JSR      SetCV            ; at top of list
  101.            JSR      SetCH_40
  102.            WRITESTR #'ProDOS '
  103.            JSR      Get_Prodos       ;print ProDOS stuff
  104. ;................................................................
  105. ;
  106. ; Print quit message:
  107. ;
  108.            LDA      #23              ;bottom line
  109.            JSR      SetCV
  110.            WRITESTR #'Press a key to quit '
  111.            WRITECH  #INVERSE         ;set inverse text mode
  112.            WRITECH  #' '             ;print pseudo-cursor
  113.            WRITECH  #NORMAL          ;set normal text mode
  114. ;................................................................
  115. ;
  116. ; Update date and time until a key is pressed:
  117. ;
  118.            WRITECH  #HOME            ;home cursor (no scrn clear)
  119.            PHA                       ;reserve space for result
  120.            _GetIRQEnable             ;check kbd interrupts
  121.            PLA                       ;get status word
  122.            STA      IRQ_Flag         ; and store it
  123.            AND      #$80             ;isolate bit 7
  124.            BEQ      Get_Time         ;kbd interrupts disabled
  125.            PushWord #1               ;1=disable
  126.            _IntSource                ;disable kbd interrupts
  127. Get_Time   LONGM                     ;set 16-bit memory and A-reg
  128.            JSR      SetCH_40
  129.            PushLong #Time_ASCII      ;ptr to ASCII time string
  130.            _ReadAsciiTime            ;read the time
  131.            PushLong #Time_ASCII      ;ptr to C-string
  132.            _WriteCString             ;print the time
  133.            SHORTM                    ;set 8-bit memory and A-reg
  134.            LDA      Key              ;check for keypress
  135.            BPL      Get_Time         ;key up so update time
  136.            STA      Strobe           ;key down so clear strobe
  137.            LONGM                     ;set 16-bit memory and A-reg
  138.            LDA      IRQ_Flag         ;get entry interrupt status
  139.            AND      #$80             ;isolate bit 7
  140.            BEQ      Restore_S3       ;entry interrupts disabled
  141.            PushWord #0               ;0=enable
  142.            _IntSource                ;re-enable kbd interrupts
  143. ;................................................................
  144. ;
  145. ; Restore entry I/O status and exit:
  146. ;
  147. Restore_S3 JSL      Restore_IO
  148.            PLB                       ;restore entry data bank
  149. GSI_Exit   RTL
  150.  
  151. ***| SUBROUTINES |***********************************************
  152. ;
  153. ; Set horizontal cursor position to 40:
  154.  
  155. SetCH_40   LDA      #40              ;fall into SetCH
  156.  
  157. ; Set horizontal cursor position:
  158. ;
  159. SetCH      SHORTM                    ;set 8-bit memory and A-reg
  160.            STA      >CH              ;stuff into $000024
  161.            LONGM                     ;set 16-bit memory and A-reg
  162.            RTS
  163. ;................................................................
  164. ;
  165. ; Set vertical cursor position:
  166. ;
  167. SetCV      DEC      A                ;compensate for later CR
  168.            SHORTM                    ;set 8-bit memory and A-reg
  169.            STA      >CV              ;stuff into $000025
  170.            LONGM                     ;set 16-bit memory and A-reg
  171.            PHY                       ;protect Y-reg from TS call
  172.            WRITELN                   ;CR
  173.            PLY                       ;restore entry Y-reg
  174.            RTS
  175. ;................................................................
  176. ;
  177. ; Set column for tool set name:
  178. ;
  179. SetCH_Name BIT      Col_Flag
  180.            BPL      SCN1             ;1st column at left margin
  181.            JSR      SetCH_40         ;2nd column at CH=40
  182. SCN1       RTS
  183. ;................................................................
  184. ;
  185. ; Set column for tool set status:
  186. ;
  187. SetCH_Stat BIT      Col_Flag
  188.            BPL      SCS1             ;we're in 1st column
  189.            LDA      #65              ;2nd column position
  190.            BRA      SCS2
  191. SCS1       LDA      #25              ;1st column position
  192. SCS2       JMP      SetCH
  193. ;................................................................
  194. ;
  195. ; Print number and name of tool set:
  196. ;
  197. ; --> Locate table location of tool set name:
  198.  
  199. Get_TS     JSR      SetCH_Name       ;set CH for TS name
  200.            SHORTM                    ;set 8-bit memory and A-reg
  201.            LDX      #$FFFF           ;prepare for X=0
  202. GTS1       CPY      #0
  203.            BEQ      Print_TS         ;table location found
  204. GTS2       INX                       ;bump table index
  205.            LDA      TS_Names,X       ;get table char
  206.            BNE      GTS2             ;not end of TS name
  207.            DEY                       ;end of TS name
  208.            BRA      GTS1
  209.  
  210. ; --> Print hex number of tool set:
  211.  
  212. Print_TS   LONGM                     ;set 16-bit memory and A-reg
  213.            INX                       ;advance to next TS name
  214.            PHX                       ;save lo start addr of name
  215.            LDA      TS_Loc           ;to get tool set number,
  216.            INC      A                ; bump tool set location
  217.            PHA                       ;tool set number (hex)
  218.            PushLong #Hex_Num         ;ptr to ASCII result
  219.            PushWord #2               ;length of ASCII string
  220.            _Int2Hex                  ;get ASCII of hex number
  221.            PushLong #Hex_Num         ;ptr to C-string number
  222.            _WriteCString             ;print C-string number
  223.  
  224. ; --> Print name of tool set:
  225.  
  226.            PLA                       ;restore lo addr of name
  227.            ADC      #TS_Names        ;add start addr of table
  228.            TAX                       ;save lo byte in X-reg
  229.            LDA      #^TS_Names       ;get hi start addr of table
  230.            ADC      #0               ;pick up carry
  231.            PHA                       ;hi ptr to tableC-string
  232.            PHX                       ;lo ptr to table C-string
  233.            _WriteCString             ;print table C-string
  234.            RTS
  235. ;................................................................
  236. ;
  237. ; Print tool set information:
  238. ;
  239. ; --> Print status of tool set:
  240.  
  241. Prt_TSInfo JSR      SetCH_Stat       ;set CH for TS status
  242.            STZ      Load_Flag        ;assume tool set loaded
  243.            PHA                       ;reserve space for result
  244.            LDX      TS_Status        ;make STATUS call
  245.            JSL      Toolbox          ; to tool set
  246.            PLA                       ;get Boolean result
  247.            BCC      PI1              ;tool set loaded
  248.            LDA      #$8000           ;signal that tool set
  249.            STA      Load_Flag        ; not loaded
  250.            LDA      #'U'             ;U=tool set unloaded
  251.            BRA      Print_Stat
  252. PI1        BEQ      PI2              ;tool set inactive
  253.            LDA      #'A'             ;A=active tool set
  254.            BRA      Print_Stat
  255. PI2        LDA      #'I'             ;I=inactive tool set
  256. Print_Stat WRITECH                   ;print tool set status
  257.            WRITESTR #'   '           ;print 3 spaces
  258.  
  259. ; --> Get version number of tool set:
  260.  
  261.            BIT      Load_Flag
  262.            BMI      RTS1             ;not loaded so no version
  263.            WRITECH  #'v'             ;print "v"
  264.            PHA                       ;reserve space for result
  265.            LDX      TS_Version       ;make VERSION call
  266.            JSL      Toolbox          ; to tool set
  267.            PLA                       ;get result into A-reg
  268. ;................................................................
  269. ;
  270. ; Print version number:
  271. ;
  272. Print_Vers PHA                       ;save 2 results
  273.            PHA                       ; on stack
  274.            XBA                       ;major version to lo byte
  275.            AND      #$7F             ;isolate major version
  276.            ORA      #$B0             ;convert to ASCII
  277.            WRITECH                   ;print major version
  278.            WRITECH  #'.'             ;print period
  279.            PLA                       ;restore 1st result
  280.            AND      #$FF             ;isolate minor version
  281.            ORA      #$B0             ;convert to ASCII
  282.            WRITECH                   ;print minor version
  283.            PLA                       ;restore 2nd result
  284.            BPL      RTS1             ;not a prototype version
  285.            WRITECH  #'p'             ;indicate prototype stage
  286. RTS1       RTS
  287. ;................................................................
  288. ;
  289. ; Print ProDOS version:
  290. ;
  291. ; --> Determine which operating system is active:
  292.  
  293. Get_Prodos LDA      OS_ID
  294.            AND      #$FF             ;isolate lo byte
  295.            BNE      ProDOS_16        ;ProDOS 16 running
  296.  
  297. ; --> ProDOS 8 running:
  298.  
  299.            WRITESTR #'8 v1.'         ;major version always 1
  300.            LDA      >KVERSION-1      ;minor version in hi byte
  301.            XBA                       ;minor version to lo byte
  302.            AND      #$FF             ;isolate lo byte
  303.            ORA      #$B0             ;convert to ASCII
  304.            WRITECH                   ;print minor version
  305.            RTS
  306.  
  307. ; --> ProDOS 16 running:
  308.  
  309. ToPD16_Err BRL      PD16_Err
  310.  
  311. ProDOS_16  WRITESTR #'16 '
  312.            _GET_VERSION GVers_Parm   ;get version
  313.            BCS      ToPD16_Err       ;error
  314.            WRITECH  #'v'
  315.            LDA      GV_Num           ;get version number in A-reg
  316.            JSR      Print_Vers       ;print version number
  317.            WRITELN                   ;CR
  318.            JSR      SetCH_40
  319.            WRITESTR #'Boot Volume: '
  320.            _GET_BOOT_VOL GBoot_Parm  ;get name of boot volume
  321.            BCS      PD16_Err         ;error
  322.            WRITELN  Boot_Name        ;print name of boot volume
  323.            JSR      SetCH_40
  324.            WRITESTR #'Application Name: '
  325.            _GET_PATH_NAME GName_Parm ;get name of application
  326.            BCS      PD16_Err         ;error
  327.            WRITESTR Appli_Name       ;print name of application
  328.            RTS
  329. PD16_Err   WRITESTR #'busy'          ;only error is BUSY error
  330.            RTS
  331. ;................................................................
  332. ;
  333. ; Print total memory in K:
  334. ;
  335. Get_TotalK PHA                       ;reserve space for result
  336.            PHA
  337.            _TotalMem                 ;get total memory
  338.            BRA      ToK_Mart         ;convert to K
  339. ;................................................................
  340. ;
  341. ; Print free memory in K:
  342. ;
  343. Get_FreeK  PHA
  344.            PHA
  345.            _FreeMem                  ;get free memory
  346.            BRA      ToK_Mart         ;convert to K
  347. ;................................................................
  348. ;
  349. ; Print largest memory block in K:
  350. ;
  351. Get_BigK   PHA
  352.            PHA
  353.            _MaxBlock                 ;get largest block
  354. ToK_Mart   PLA                       ;memory hi
  355.            PLY                       ;memory lo
  356. ;................................................................
  357. ;
  358. ; Convert bytes to kilobytes. Enter with Y=hi word and A=lo word:
  359. ;
  360. ; --> Divide 4-byte value by 10:
  361.  
  362. K_Mart     STY      Memory_Hi        ;hi word in memory
  363.            LDX      #10              ;counter
  364. K1         LSR      Memory_Hi        ;shift hi word
  365.            ROR      A                ;shift lo word
  366.            DEX
  367.            BNE      K1               ;do it 10 times
  368.  
  369. ; --> Convert result in A-reg to ASCII and print K value:
  370.  
  371.            PHA                       ;K number
  372.            PushLong #Dec_Num         ;ptr to ASCII result
  373.            PushWord #4               ;length of ASCII string
  374.            PushWord #0               ;unsigned number
  375.            _Int2Dec                  ;get ASCII of dec number
  376.            PushLong #Dec_Num         ;ptr to C-string number
  377.            _WriteCString             ;print C-string number
  378.            RTS
  379.  
  380.            END
  381.  
  382.            COPY     SLOT3.IO.ASM
  383.  
  384. ***| DATA |******************************************************
  385.  
  386. GSI_Data   DATA
  387.  
  388. ; Table of tool set names:
  389.  
  390. TS_Num     DC       I2'28'                     ;# tool sets
  391. TS_Names   DC       C'Tool Locator',I1'0'              ;$01
  392.            DC       C'Memory Manager',I1'0'            ;$02
  393.            DC       C'Miscellaneous Tools',I1'0'       ;$03
  394.            DC       C'QuickDraw II',I1'0'              ;$04
  395.            DC       C'Desk Manager',I1'0'              ;$05
  396.            DC       C'Event Manager',I1'0'             ;$06
  397.            DC       C'Scheduler',I1'0'                 ;$07
  398.            DC       C'Sound Manager',I1'0'             ;$08
  399.            DC       C'DeskTop Bus Tools',I1'0'         ;$09
  400.            DC       C'SANE',I1'0'                      ;$0A
  401.            DC       C'Integer Math Tools',I1'0'        ;$0B
  402.            DC       C'Text Tools',I1'0'                ;$0C
  403.            DC       C'RAM Disk Tools',I1'0'            ;$0D
  404.            DC       C'Window Manager',I1'0'            ;$0E
  405.            DC       C'Menu Manager',I1'0'              ;$0F
  406.            DC       C'Control Manager',I1'0'           ;$10
  407.            DC       C'System Loader',I1'0'             ;$11
  408.            DC       C'QuickDraw Aux Tools',I1'0'       ;$12
  409.            DC       C'Print Manager',I1'0'             ;$13
  410.            DC       C'LineEdit',I1'0'                  ;$14
  411.            DC       C'Dialog Manager',I1'0'            ;$15
  412.            DC       C'Scrap Manager',I1'0'             ;$16
  413.            DC       C'Stnd File Operations',I1'0'      ;$17
  414.            DC       C'Disk Utilities',I1'0'            ;$18
  415.            DC       C'Note Synthesizer',I1'0'          ;$19
  416.            DC       C'Note Sequencer',I1'0'            ;$1A
  417.            DC       C'Font Manager',I1'0'              ;$1B
  418.            DC       C'List Manager',I1'0'              ;$1C
  419.  
  420. ; Storage locations
  421.  
  422. TS_Status  DS       2                ;tool set status call
  423.  
  424. TS_Version DS       2                ;tool set version number
  425.  
  426. TS_Loc     DS       2                ;position in tool set table
  427.  
  428. Col_Flag   DS       2                ;column flag (PL=1st,MI=2nd)
  429.  
  430. Load_Flag  DS       2                ;load flag (MI=TS unloaded)
  431.  
  432. IRQ_Flag   DS       2                ;IRQ flag (on=bit 7 set)
  433.  
  434. Hex_Num    DS       2                ;ASCII string of hex number
  435.            DC       C'-',I1'0'       ;hyphen and zero terminator
  436.  
  437. Dec_Num    DS       4                ;ASCII string of dec number
  438.            DC       C'K',I1'0'       ;"K" and zero terminator
  439.  
  440. Time_ASCII DS       20               ;always 20 chars
  441.            DC       I1'0'            ;zero terminator
  442.  
  443. Memory_Hi  DS       2                ;hi order memory byte
  444.  
  445. Boot_Name  DS       18               ;boot volume name string
  446.  
  447. Appli_Name DS       16               ;application name string
  448.  
  449. ; Parameter list for ProDOS 16 call:
  450.  
  451. GVers_Parm ANOP                      ;GET_VERSION parms
  452. GV_Num     DS       2                ;lo=minor, hi=major
  453.  
  454. GBoot_Parm ANOP                      ;GET_BOOT_VOL parms
  455.            DC       I4'Boot_Name'    ;ptr to name of boot volume
  456.  
  457. GName_Parm ANOP                      ;GET_NAME parms
  458.            DC       I4'Appli_Name'   ;ptr to application name
  459.  
  460.            END
  461.